class CreateOuterExpenses < ActiveRecord::Migration
  def self.up
    create_table :outer_expenses, :force => true do |t|
      t.references :tour_group, :null => false
      t.decimal :lodging_cost, :precision => 8, :scale => 2, :default => 0, :null => false
      t.decimal :travel_cost, :precision => 8, :scale => 2, :default => 0, :null => false
      t.decimal :food_cost, :precision => 8, :scale => 2, :default => 0, :null => false
      t.decimal :ticket_cost, :precision => 8, :scale => 2, :default => 0, :null => false
      t.decimal :subsidy_for_guide, :precision => 8, :scale => 2, :default => 0, :null => false
      t.decimal :airticket_cost, :precision => 8, :scale => 2, :default => 0, :null => false
      t.decimal :trainticket_cost, :precision => 8, :scale => 2, :default => 0, :null => false
      t.decimal :total_cost, :precision => 8, :scale => 2, :default => 0, :null => false
      t.timestamps
    end
    execute "ALTER TABLE outer_expenses ADD CONSTRAINT fk_outer_expenses_tour_group FOREIGN KEY (tour_group_id) REFERENCES tour_groups(id)"
  end

  def self.down
    drop_table :outer_expenses
  end
end
